//
//  StarsView.m
//  LeeZheDouBan
//
//  Created by LeeZhe on 15/1/16.
//  Copyright (c) 2015年 LeeZhe. All rights reserved.
//

#import "StarsView.h"

@implementation StarsView

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
      
        
    }
    return self;
}
- (void)produceStarView:(NSInteger)stars
{
  
    if (stars % 10 == 0) {
        for (NSInteger i = 0; i < stars / 10; i++)
        {
            UIImageView *view = [[UIImageView alloc] initWithFrame:CGRectMake(self.frame.size.width * i / 5, 0, self.frame.size.width / 5,self.frame.size.height)];
            view.image = [UIImage imageNamed:@"lan.png"];
            [self addSubview:view];
        }
        
        if (stars < 30) {
            for (NSInteger j = stars / 10; j < 5; j++)
            {
                UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(self.frame.size.width * j / 5, 0, self.frame.size.width / 5, self.frame.size.height)];
                imageView.image = [UIImage imageNamed:@"bai.png"];
                [self addSubview:imageView];
                //            [imageView release];
            }
        }else
        {
            for (NSInteger i = stars / 10; i < 5; i++) {
                UIImageView *view = [[UIImageView alloc] initWithFrame:CGRectMake(self.frame.size.width * i / 5,0,self.frame.size.width / 5,self.frame.size.height)];
                view.image = [UIImage imageNamed:@"bai.png"];
                [self addSubview:view];
            }
            
            
            
        }
        

            
            //            [view release];
    }
    
        
       
    if(stars % 10 != 0) {
        for (NSInteger i = 0; i < stars / 10; i++)
        {
            UIImageView *view = [[UIImageView alloc] initWithFrame:CGRectMake(self.frame.size.width * i / 5, 0, self.frame.size.width / 5,self.frame.size.height)];
            view.image = [UIImage imageNamed:@"lan.png"];
            [self addSubview:view];
        }
        UIImageView *viewOne = [[UIImageView alloc] initWithFrame:CGRectMake((stars / 10) * self.frame.size.width / 5, 0, self.frame.size.width / 5,self.frame.size.height)];
        viewOne.image = [UIImage imageNamed:@"bailan.png"];
        [self addSubview:viewOne];
//        [view release];
        // 5  4个 1/5处
        // 15 3个 2/5处
        // 25 2个 3/5处
        // 35 1个 4/5处
        // 45 0
        if (stars == 5) {
            for (NSInteger i = 1; i < 5; i++) {
                UIImageView *view = [[UIImageView alloc] initWithFrame:CGRectMake(self.frame.size.width * i / 5 , 0, self.frame.size.width / 5, self.frame.size.height)];
                view.image = [UIImage imageNamed:@"bai.png"];
                [self addSubview:view];
                [view release];
            }
        }else if (stars == 15){
            for (NSInteger i = 2; i < 5; i++) {
                UIImageView *view = [[UIImageView alloc] initWithFrame:CGRectMake(self.frame.size.width * i / 5 , 0, self.frame.size.width / 5, self.frame.size.height)];
                view.image = [UIImage imageNamed:@"bai.png"];
                [self addSubview:view];
                [view release];
            }
            
        }
        else if (stars == 25)
        {
            for (NSInteger i = 3; i < 5; i++) {
                UIImageView *view = [[UIImageView alloc] initWithFrame:CGRectMake(self.frame.size.width * i / 5 , 0, self.frame.size.width / 5, self.frame.size.height)];
                view.image = [UIImage imageNamed:@"bai.png"];
                [self addSubview:view];
                [view release];
            }
        }else if (stars == 35)
        {
            for (NSInteger i = 4; i < 5; i++) {
                UIImageView *view = [[UIImageView alloc] initWithFrame:CGRectMake(self.frame.size.width * i / 5 , 0, self.frame.size.width / 5, self.frame.size.height)];
                view.image = [UIImage imageNamed:@"bai.png"];
                [self addSubview:view];
                [view release];
            }
        }
    
        
       
        

    }
    
    
    
    
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
    // Drawing code
}
*/

@end
